<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>docker命令 | 逆流时光~</title><meta name="keywords" content="docker"><meta name="author" content="FantasticCode,1443996278@qq.com"><meta name="copyright" content="FantasticCode"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="####1. docker镜像由本地push到远程仓库 第一步，登录远程仓库。docker login http:&#x2F;&#x2F;192.168.0.1 第二步，创建私有仓库的项目文件目录abc。 第三步，给推送的镜像打tag。docker tag 2e25d8496557 192.168.0.1&#x2F;abc&#x2F;arc:1334 注意： 2e25d8496557：IMAGE ID，可以用docker images">
<meta property="og:type" content="article">
<meta property="og:title" content="docker命令">
<meta property="og:url" content="https://yyj_challenged.gitee.io/2020/12/15/docker%E5%91%BD%E4%BB%A4/index.html">
<meta property="og:site_name" content="逆流时光~">
<meta property="og:description" content="####1. docker镜像由本地push到远程仓库 第一步，登录远程仓库。docker login http:&#x2F;&#x2F;192.168.0.1 第二步，创建私有仓库的项目文件目录abc。 第三步，给推送的镜像打tag。docker tag 2e25d8496557 192.168.0.1&#x2F;abc&#x2F;arc:1334 注意： 2e25d8496557：IMAGE ID，可以用docker images">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg16.jpg">
<meta property="article:published_time" content="2020-12-14T16:00:00.000Z">
<meta property="article:modified_time" content="2022-05-30T07:08:52.721Z">
<meta property="article:author" content="FantasticCode">
<meta property="article:tag" content="docker">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg16.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://yyj_challenged.gitee.io/2020/12/15/docker%E5%91%BD%E4%BB%A4/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//hm.baidu.com"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="manifest" href="/img/pwa/manifest.json"/><link rel="apple-touch-icon" sizes="180x180" href="/img/pwa/apple-touch-icon.png"/><link rel="icon" type="image/png" sizes="32x32" href="/img/pwa/32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/img/pwa/16.png"/><link rel="mask-icon" href="/img/pwa/safari-pinned-tab.svg" color="#5bbad5"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@6/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.css" media="print" onload="this.media='all'"><script>var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?67fada177b615329655b957d30519c62";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: {"appId":"UVE3L335VP","apiKey":"5c662b130a966e23356d9dd1739405cd","indexName":"dev_myblog","hits":{"per_page":6},"languages":{"input_placeholder":"搜索文章","hits_empty":"找不到您查询的内容：${query}","hits_stats":"找到 ${hits} 条结果，用时 ${time} 毫秒"}},
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: FantasticCode","link":"链接: ","source":"来源: 逆流时光~","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"bottom-left"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery@2/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: false,
  isAnchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'docker命令',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-05-30 15:08:52'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.2.0"><link rel="alternate" href="/atom.xml" title="逆流时光~" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/avatar.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">20</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">32</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">6</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/%E9%9F%B3%E4%B9%90"><i class="fa-fw /music/"></i><span> 0</span></a></li><li><a class="site-page child" href="/%E5%9B%BE%E7%89%87"><i class="fa-fw /picture/"></i><span> 1</span></a></li><li><a class="site-page child" href="/%E7%94%B5%E5%BD%B1"><i class="fa-fw /movie/"></i><span> 2</span></a></li><li><a class="site-page child" href="/%E4%B9%A6%E7%B1%8D"><i class="fa-fw /books/"></i><span> 3</span></a></li><li><a class="site-page child" href="/%E6%B8%B8%E6%88%8F"><i class="fa-fw /game/"></i><span> 4</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/treasure/"><i class="fa-fw fas fa-link"></i><span> 宝藏</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg16.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">逆流时光~</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 娱乐</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/%E9%9F%B3%E4%B9%90"><i class="fa-fw /music/"></i><span> 0</span></a></li><li><a class="site-page child" href="/%E5%9B%BE%E7%89%87"><i class="fa-fw /picture/"></i><span> 1</span></a></li><li><a class="site-page child" href="/%E7%94%B5%E5%BD%B1"><i class="fa-fw /movie/"></i><span> 2</span></a></li><li><a class="site-page child" href="/%E4%B9%A6%E7%B1%8D"><i class="fa-fw /books/"></i><span> 3</span></a></li><li><a class="site-page child" href="/%E6%B8%B8%E6%88%8F"><i class="fa-fw /game/"></i><span> 4</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/treasure/"><i class="fa-fw fas fa-link"></i><span> 宝藏</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">docker命令</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-12-14T16:00:00.000Z" title="发表于 2020-12-15 00:00:00">2020-12-15</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-05-30T07:08:52.721Z" title="更新于 2022-05-30 15:08:52">2022-05-30</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E6%9C%8D%E5%8A%A1%E5%99%A8/">服务器</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>13分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="docker命令"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><p>####1. docker镜像由本地push到远程仓库</p>
<p>第一步，登录远程仓库。<code>docker login http://192.168.0.1</code></p>
<p>第二步，创建私有仓库的项目文件目录<code>abc</code>。</p>
<p>第三步，给推送的镜像打tag。<code>docker tag 2e25d8496557 192.168.0.1/abc/arc:1334</code></p>
<p>注意： 2e25d8496557：IMAGE ID，可以用<code>docker images arc:1334</code>查看</p>
<p>192.168.0.1：远程仓库地址</p>
<p>abc：项目名称</p>
<p>arc：镜像名称</p>
<p>1334：镜像版本号</p>
<p>第四步，推送镜像到远程仓库。<code>docker push 192.168.0.1/abc/arc:1334</code></p>
<h4 id="2-docker镜像由本地push到dockerhub">2. docker镜像由本地push到dockerhub</h4>
<p>第一步，在DockerHub上注册一个用户，注册地址为<code>https://hub.docker.com</code>。</p>
<p>第二步，在终端登录dockerHub。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">运行 docker login 命令，按照提示输入注册的用户名和密码即可登录</span><br><span class="line">[root@k8s-node-3 home]# docker login</span><br><span class="line">Login with your Docker ID to push and pull images from Docker Hub. If you don&#x27;t have a Docker ID, head over to https://hub.docker.com to create one.</span><br><span class="line">Username: 10220208</span><br><span class="line">Password: </span><br><span class="line">Login Succeeded</span><br></pre></td></tr></table></figure>
<p>第三步，用docker tag命令修改本地镜像名。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">（1） push的规范是： docker push  注册用户名 / 镜像名</span><br><span class="line">（2） docker tag 修改本地镜像名：如 docker tag kubeflow/pytorch-dist-mnist-test:1.5 10220208/pytorch-dist-mnist-test-1.5:v1.5</span><br></pre></td></tr></table></figure>
<p>第四步，push镜像到dockerHub</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">docker push 10220208/pytorch-dist-mnist-test-1.5:v1.5</span><br><span class="line">push 速度根据镜像大小而定，大的镜像push比较慢，耐心等待即可，如果push失败，则重新push即可。</span><br></pre></td></tr></table></figure>
<h4 id="3-搜索镜像">3. 搜索镜像</h4>
<p><code>docker search 想要查询的镜像</code></p>
<p>参数介绍如下：</p>
<table>
<thead>
<tr>
<th style="text-align:left">参数</th>
<th style="text-align:left">介绍</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left">–automated=true</td>
<td style="text-align:left">false	仅显示自动创建的镜像，默认为否</td>
</tr>
<tr>
<td style="text-align:left">–no-trunc=true</td>
<td style="text-align:left">false	输出信息不截断显示，默认为否</td>
</tr>
<tr>
<td style="text-align:left">-s，–stars=X</td>
<td style="text-align:left">指定仅显示评价为指定星级以上的镜像，默认为0，即输出所有满足条件的镜像</td>
</tr>
</tbody>
</table>
<h4 id="4-下载镜像">4. 下载镜像</h4>
<p><code>docker pull &lt;image_name&gt;:&lt;tag&gt;</code>     其中image_name为镜像名称，tag为镜像的版本</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>介绍</th>
</tr>
</thead>
<tbody>
<tr>
<td>-a，–all-tags=true | false</td>
<td>表示是否获取仓库中的所有镜像，默认为否</td>
</tr>
</tbody>
</table>
<p>查看镜像、容器、数据卷所占用的空间命令：<code>docker system df</code></p>
<h4 id="5-列出镜像目录">5. 列出镜像目录</h4>
<table>
<thead>
<tr>
<th>参数</th>
<th>介绍</th>
</tr>
</thead>
<tbody>
<tr>
<td>-a，–all=true | false</td>
<td>列出所有的镜像文件(包含临时文件)，默认为否</td>
</tr>
<tr>
<td>–digests=true | false</td>
<td>列出镜像的数字摘要值，默认为否</td>
</tr>
<tr>
<td>-f，–filter=[]</td>
<td>过滤列出的镜像，如dangling=true只显示没有被使用的镜像，也可指定带有特定标注的镜像等</td>
</tr>
<tr>
<td>–format=“TEMPLATE”</td>
<td>控制输出格式，如.ID代表ID信息，.Repository代表仓库信息等</td>
</tr>
<tr>
<td>–no-trunc=true | false</td>
<td>对输出结果中太长的部分是否进行截断，如镜像的ID信息，默认为是</td>
</tr>
<tr>
<td>-q，–quiet=true | false</td>
<td>仅输出ID信息，默认为否</td>
</tr>
</tbody>
</table>
<h4 id="6-创建容器">6. 创建容器</h4>
<p><code>docker run -i -t --name &lt;container_name&gt; &lt;image_name&gt; /bin/bash</code></p>
<p>参数解释：</p>
<ul>
<li>参数<code>-t</code>让Docker分配一个伪终端并绑定在容器的标准输入上，<code>-i</code>让容器的标准输入保持打开</li>
<li>–name &lt;container_name&gt;为设定容器名称，如果不设定docker会自定义一个容器名称</li>
<li>&lt;image_name&gt;为镜像名称</li>
<li>/bin/bash为启动一个bash交互终端</li>
</ul>
<p>其他的参数介绍</p>
<ul>
<li>-a stdin：指定标准输入输出内容类型，可选 STDIN/STDOUT/STDERR 三项；</li>
<li>-d：后台运行容器，并返回容器ID；</li>
<li>-i：以交互模式运行容器，通常与 -t 同时使用；</li>
<li>-t：为容器重新分配一个伪输入终端，通常与 -i 同时使用；</li>
<li>–name=“nginx-lb”：为容器指定一个名称；</li>
<li>–dns 8.8.8.8：指定容器使用的DNS服务器，默认和宿主一致；</li>
<li>–dns-search <a target="_blank" rel="noopener" href="http://example.com">example.com</a>：指定容器DNS搜索域名，默认和宿主一致；</li>
<li>-h “mars”：指定容器的hostname；</li>
<li>-e username=“ritchie”：设置环境变量；</li>
<li>–env-file=[]：从指定文件读入环境变量；</li>
<li>–cpuset=“0-2” or --cpuset=“0,1,2”：绑定容器到指定CPU运行；</li>
<li>-m：设置容器使用内存最大值；</li>
<li>–net=“bridge”：指定容器的网络连接类型，支持 bridge/host/none/container: 四种类型；</li>
<li>–link=[]：添加链接到另一个容器，可以使得该容器与其他容器可以进行网络访问；</li>
<li>–expose=[]：开放一个端口或一组端口；</li>
</ul>
<h4 id="7-查看容器状态">7. 查看容器状态</h4>
<p><code>docker start &lt;container_name&gt;</code>     可以通过docker ps查看容器，可以看到状态为UP开启</p>
<h4 id="8-容器的重启、停止">8. 容器的重启、停止</h4>
<p><code>docker restart &lt;container_name&gt;</code></p>
<p><code>docker stop &lt;container_name&gt;</code></p>
<h4 id="9-获取容器的Root权限">9. 获取容器的Root权限</h4>
<p><code>docker exec -ti -u root &lt;container_name&gt; bash</code></p>
<h4 id="10-查看容器的环境变量">10. 查看容器的环境变量</h4>
<p><code>docker exec -it &lt;container_name&gt; env</code></p>
<h4 id="11-连接容器">11. 连接容器</h4>
<p><code>docker attach &lt;container_name&gt;或&lt;container_id&gt;</code></p>
<p>参数介绍：</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>–detach-keys[=[]]</td>
<td>指定退出attach模式的快捷键序列，默认是 CTRL-p，CTRL-q</td>
</tr>
<tr>
<td>–no-stdin=true</td>
<td>false	是否关闭标准输入，默认是保持打开</td>
</tr>
<tr>
<td>–sig-proxy=true</td>
<td>false	是否代理收到的系统信号给应用进程，默认为true</td>
</tr>
</tbody>
</table>
<h4 id="12-外部运行容器内命令">12. 外部运行容器内命令</h4>
<p><code>docker exec &lt;container_name&gt;或&lt;container_id&gt; 需要执行的命令</code></p>
<p>eg: <code>docker exec docker_contain001 echo &quot;hello world&quot;</code></p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>-i, --interactive=true | false</td>
<td>打开标准输入接受用户输入命令，默认为false</td>
</tr>
<tr>
<td>–privileged=true | false</td>
<td>是否给执行命令以高权限，默认为false</td>
</tr>
<tr>
<td>-t, --tty=true | false</td>
<td>分配伪终端，默认为false</td>
</tr>
<tr>
<td>-u, --user=“”</td>
<td>执行命令的用户名或ID</td>
</tr>
</tbody>
</table>
<p>推荐使用：<code>docker exec -it &lt;container_name&gt; /bin/bash</code> 进入容器并打开终端</p>
<h4 id="13-删除容器、镜像">13. 删除容器、镜像</h4>
<p>容器正在运行，强行删除容器：<code>docker rm -f &lt;container_name&gt;</code></p>
<p>容器没有运行，强行删除容器：<code>docker rm &lt;container_name&gt;</code></p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>-f, --force=false</td>
<td>是否强行终止并删除一个运行中的容器</td>
</tr>
<tr>
<td>-l, --link=false</td>
<td>删除容器的连接，但保留容器</td>
</tr>
<tr>
<td>-v, --volumes=false</td>
<td>删除容器挂载的数据卷</td>
</tr>
</tbody>
</table>
<p>镜像正在容器中运行，强行删除镜像：<code>docker rmi -f &lt;image_name&gt;:&lt;tag&gt;</code></p>
<p>镜像没有正在容器中运行，强行删除镜像：<code>docker rmi &lt;image_name&gt;:&lt;tag&gt;</code></p>
<p>注意：<strong>先删除容器再删除镜像！</strong></p>
<h4 id="14-导入和导出容器">14. 导入和导出容器</h4>
<p>导出容器(导出一个已经创建的容器到一个文件)：<code>docker export [-o | --output [=&quot;&quot;]] container_name</code></p>
<p>可以通过-o选项来指定导出的tar文件名，也可以直接通过重定向来实现。例如：</p>
<blockquote>
<p>docker export -o test_for_run.tar ce5</p>
<p>docker export e81 &gt; test_for_stop.tar</p>
</blockquote>
<p>可将导出的tar文件传输到其他机器上，然后再通过导入命令导入到系统中，从而实现容器的迁移</p>
<p>导入容器：<code>docker import [-c | --change [= [] ] ] [-m | --message[=MESSAGE]] file|URL| - [REPOSITORY[:TAG]]</code></p>
<p>用户可以通过-c，–change=[]选项在导入的同时执行对容器进行修改的Dockerfile指令。例如：</p>
<p><code>docker import test_for_run.tar - test/ubuntu:v1.0</code></p>
<p>docker load命令可以导入镜像存储文件到本地镜像库，docker import命令可以导入一个容器快照到本地镜像库</p>
<p>这两者的区别在于容器快照文件将丢弃所有的历史记录和元数据信息（仅保存容器当时的快照状态），而镜像存储文件将保存完整记录，体积也更大。此外，从容器快照文件导入时可以重新指定标签等元数据信息。</p>
<h4 id="15-查看镜像历史记录">15. 查看镜像历史记录</h4>
<p><code>docker history &lt;image_name&gt;:&lt;tag&gt;</code></p>
<h4 id="16-使用cp命令复制文件">16. 使用cp命令复制文件</h4>
<p>将docker容器当中的文件复制到本地(容器必须是运行状态):</p>
<p><code>docker cp &lt;container_name&gt;:&lt;需要复制的容器文件路径&gt; &lt;复制到本地主机的文件路径&gt;</code></p>
<p>将本地文件复制到docker容器中(容器必须是运行状态):</p>
<p><code>docker cp &lt;本地文件路径&gt; &lt;container_name&gt;:&lt;复制到容器文件路径&gt;</code></p>
<h4 id="17-使用commit命令提交容器修改">17. 使用commit命令提交容器修改</h4>
<p><code>docker commit &lt;options&gt; &lt;container_name&gt; &lt;image_name&gt;:&lt;tag&gt;</code></p>
<p>options参数如下：</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>介绍</th>
</tr>
</thead>
<tbody>
<tr>
<td>-a，–author=“”</td>
<td>作者信息</td>
</tr>
<tr>
<td>-c，–change=[]</td>
<td>提交的时候执行Dockerfile指令，包括CMD|ENTRYPOINT|ENV|LABEL|ONBUILD|USER|VOLUME|WORKDIR|等</td>
</tr>
<tr>
<td>-m，–message=“”</td>
<td>提交信息</td>
</tr>
<tr>
<td>-p，–pause=true</td>
<td>提交时暂停容器运行</td>
</tr>
</tbody>
</table>
<h4 id="18-使用diff命令检查容器文件的变动">18. 使用diff命令检查容器文件的变动</h4>
<p><code>docker diff &lt;container_name&gt;</code></p>
<p>A表示添加的文件;   C表示修改的文件;   D表示删除的文件</p>
<h4 id="19-使用inspect查看容器、镜像详细信息">19. 使用inspect查看容器、镜像详细信息</h4>
<p>查看容器的详细信息：<code>docker inspect &lt;container_name&gt;</code></p>
<p>查看镜像的详细信息：<code>docker inspect &lt;image_name&gt;:&lt;tag&gt;</code></p>
<p>当我们只要其中一项内容时，可以使用参数-f来指定，过滤节点根据json的结构来获取</p>
<p><code>docker inspect -f &#123;&#123;过滤节点&#125;&#125; &lt;container_name&gt;/&lt;image_name&gt;</code></p>
<p>eg:  获取单层节点信息，获取Id信息，则使用   <code>docker inspect -f '&#123;&#123;.Id&#125;&#125;' &lt;container_name&gt;/&lt;image_name&gt;</code></p>
<p>​       获取多层节点信息，获取Status信息，则使用    <code>docker inspect -f '&#123;&#123;.State.Status&#125;&#125;' &lt;container_name&gt;/&lt;image_name&gt;</code></p>
<h4 id="20-基于本地模板导入">20. 基于本地模板导入</h4>
<p>用户可以直接从一个操作系统模板文件导入一个镜像，命令： <code>docker import [OPTIONS] file | URL| - [REPOSITORY[:TAG]]</code></p>
<p>eg:      <code>cat ubuntu-14.04-x86_64-minimal.tar.gz | docker import - ubuntu:14.04</code></p>
<h4 id="21-导出和载入镜像">21. 导出和载入镜像</h4>
<p>导出镜像：<code>docker save -o &lt;本地文件名称&gt; &lt;image_name:tag&gt;</code></p>
<p>载入镜像：<code>docker load --input &lt;本地文件名称&gt;</code>   或  <code>docker load &lt; &lt;本地文件名称&gt;</code></p>
<h4 id="22-搭建docker私有仓库服务器">22. 搭建docker私有仓库服务器</h4>
<p>第一步， 下载docker注册服务器镜像。<code>docker pull registry:latest</code></p>
<p>第二步，运行注册服务器。</p>
<p><code>docker run -d -p &lt;主机port&gt;:&lt;容器port&gt; --name &lt;container_name&gt; -v &lt;存储目录&gt;:&lt;存储目录&gt; &lt;image_name&gt;</code></p>
<p>参数介绍：-d:  将容器设置为后台运行；-p:  设置容器端口；-v:  指定存储目录(需要建立对应关系，需要一致)</p>
<p>第三步，上传镜像(需要有tag标签)。</p>
<p>使用<code>docker tag &lt;image_name&gt;:&lt;tag&gt; &lt;new_image_name&gt;:&lt;tag&gt;</code>打上标签，向私有仓库上传镜像必须创建tag标签</p>
<p>new_image_name必须为&lt;私有仓库地址&gt;/&lt;image_name&gt;(eg: localhost:8001/ubuntu:18.01)；</p>
<p>使用<code>docker push &lt;new_image_name&gt;:&lt;tag&gt;</code>上传镜像；</p>
<p>使用<code>curl localhost:8001/ubuntu:18.01/_catalog</code>查看私有仓库当中的镜像；</p>
<p>在其他机器当中使用如下命令下载私有仓库的镜像。<code>docker pull &lt;私有仓库的IP&gt;:&lt;Port&gt;/&lt;image_name&gt;:&lt;tag&gt;</code></p>
<h4 id="23-Dockerfile介绍">23. Dockerfile介绍</h4>
<p>一般而言，Dockerfile分为四部分：基础镜像信息、维护者信息、镜像操作指令和容器启动时执行指令。一开始指明所基于的镜像名称，接下来一般是说明维护者信息。后面则是镜像操作指令，例如RUN指令，RUN指令将对镜像执行跟随的命令。每运行一条RUN指令，镜像就添加新的一层，并提交。最后是CMD指令，用来指定运行容器时的操作命令。</p>
<p>指令说明如下表：</p>
<table>
<thead>
<tr>
<th>指令</th>
<th>说明</th>
<th>命令</th>
</tr>
</thead>
<tbody>
<tr>
<td>FROM</td>
<td>指定所创建镜像的基础镜像</td>
<td>FROM centos:latest</td>
</tr>
<tr>
<td>MAINTAINER</td>
<td>指定维护者信息</td>
<td>MAINTAINER yyj</td>
</tr>
<tr>
<td>RUN</td>
<td>运行镜像时运行的Shell命令</td>
<td>RUN [“yum”,“install”,“httpd”]<br>RUN yum install httpd</td>
</tr>
<tr>
<td>CMD</td>
<td>指定启动容器时默认执行的Shell命令</td>
<td>CMD [“-c”,“/start.sh”]<br />CMD [“/usr/sbin/sshd”,“-D”]<br/>CMD /usr/sbin/sshd -D</td>
</tr>
<tr>
<td>LABEL</td>
<td>指定生成镜像的元数据标签信息</td>
<td>LABEL <key>=<value> …</td>
</tr>
<tr>
<td>EXPOSE</td>
<td>声明镜像内服务所监听的端口</td>
<td>EXPOST 80 443</td>
</tr>
<tr>
<td>ENV</td>
<td>指定容器内的环境变量</td>
<td>ENV MYSQL_ROOT_PASSWORD 123456</td>
</tr>
<tr>
<td>ADD</td>
<td>复制指定的<src>路径下的内容到容器中的<dest>路径下，<src>可以为URL;如果为tar文件，会自动解压到<dest>路径下</td>
<td>ADD <src>…<dest><br/>ADD [“<src>”,…“<dest>”]<br/>ADD <a target="_blank" rel="noopener" href="https://xxx.com/html.tar.gz">https://xxx.com/html.tar.gz</a> /var/www/html<br/>ADD html.tar.gz /var/www/html<br/></td>
</tr>
<tr>
<td>COPY</td>
<td>复制本地主机的<src>路径下的内容到镜像中的<dest>路径下;一般情况下推荐使用COPY，而不是ADD，但是如果拷贝到容器中的文件需要自动解压就需要使用ADD</td>
<td>COPY ./start.sh /start.sh</td>
</tr>
<tr>
<td>ENTRYPOINT</td>
<td>指定镜像的默认入口，运行容器时执行的Shell命令</td>
<td>ENTRYPOINT [“/bin/bash”,“-c”,“/start.sh”]<br/>ENTRYPOINT /bin/bash -c ‘/start.sh’</td>
</tr>
<tr>
<td>VOLUME</td>
<td>创建数据卷挂载点，指定容器挂载点到宿主机自动生成的目录或其他容器</td>
<td>VOLUME [“/var/lib/mysql”]</td>
</tr>
<tr>
<td>USER</td>
<td>为RUN、CMD和ENTRYPOINT执行命令指定运行用户</td>
<td>USER <user>[:<group>] or USER <UID>[:<GID>]</td>
</tr>
<tr>
<td>WORKDIR</td>
<td>为RUN、CMD和ENTRYPOINT、COPY和ADD配置工作目录，在进入容器时就会自动切换到指定的workdir目录中。可以使用多个WORKDIR指令，后续命令如果参数是相对路径，则会基于之前命令指定的路径。</td>
<td>WORKDIR /data</td>
</tr>
<tr>
<td>ARG</td>
<td>指定镜像内使用的参数（例如版本号信息等），在构造镜像时指定一些参数</td>
<td>FROM centos:6<br/>ARG user #ARG user=root<br/>USER $user<br/>#docker build --build-arg user=luozelin Dockerfile</td>
</tr>
<tr>
<td>ONBUILD</td>
<td>配置当所创建的镜像作为其他镜像的基础镜像时，所执行的创建操作指令</td>
<td></td>
</tr>
<tr>
<td>STOPSIGNAL</td>
<td>容器退出的信号值</td>
<td></td>
</tr>
<tr>
<td>HEALTHCHECK</td>
<td>如何进行健康检查</td>
<td>HEALTHCHECK --interval=5m --timeout=3s --retries=3 CMD curl -f <a target="_blank" rel="noopener" href="http://localhost/">http://localhost/</a> || exit 1</td>
</tr>
<tr>
<td>SHELL</td>
<td>指定使用shell时的默认shell类型</td>
<td></td>
</tr>
</tbody>
</table>
<p><strong>RUN</strong>:运行指定命令，格式为<strong>RUN <command><strong>或</strong>RUN [“executable”，“param1”，“param2”]</strong></p>
<p>每条RUN指令将在当前镜像的基础上执行指定指令，并提交为新的镜像。</p>
<p><strong>CMD</strong>:CMD指令用来指定启动容器时默认执行的命令，支持三种格式：</p>
<p>第一种：CMD [“executable”,“param1”,“param2”]使用exec执行，是推荐使用的方式</p>
<p>第二种：CMD command param1 param2 在/bin/sh中执行，提供给需要交互的应用</p>
<p>第三种：CMD [“param1”,“param2”] 只能有一条CMD命令，如果指定了多条命令，只有最后一条会被执行</p>
<p>如果用户启动容器时手动指定了运行的命令（作为run的参数），则会覆盖CMD指定的命令</p>
<h4 id="24-基于Dockerfile创建镜像">24. 基于Dockerfile创建镜像</h4>
<p>基本格式为 <strong>docker build [options] 内容路径</strong>，该命令将读取指定路径下（包括子目录）的Dockerfile，并将该路径下的所有内容发送给Docker服务端，由服务端来创建镜像。因此除非生成镜像需要，否则一般建议放置Dockerfile的目录为空目录。注意如下：</p>
<p>其一、如果使用非内容路径下的Dockerfile，可以通过 -f 选项来指定其路径</p>
<p>其二、要指定生成镜像的标签信息，可以使用 -t 选项</p>
<p>例：指定Dockerfile所在路径为/tmp/docker_builder/，并且希望生成镜像标签为build_repo/first_image</p>
<p><code>docker build -t build_repo/first_image /tmp/docker_builder/</code></p>
<p>可以通过<code>.dockerignore</code>文件（每一行添加一条匹配模式）来让Docker忽略匹配模式路径下的目录和文件</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://yyj_challenged.gitee.io">FantasticCode</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://yyj_challenged.gitee.io/2020/12/15/docker%E5%91%BD%E4%BB%A4/">https://yyj_challenged.gitee.io/2020/12/15/docker%E5%91%BD%E4%BB%A4/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://yyj_challenged.gitee.io" target="_blank">逆流时光~</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/docker/">docker</a></div><div class="post_share"><div class="social-share" data-image="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg16.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/gh/overtrue/share.js@master/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2020/12/15/shiro%E6%A1%86%E6%9E%B6/"><img class="prev-cover" src="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg12.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">shiro框架讲解</div></div></a></div><div class="next-post pull-right"><a href="/2020/12/15/AOP/"><img class="next-cover" src="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg10.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">AOP学习</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div id="gitalk-container"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="/img/avatar.jpg" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">FantasticCode</div><div class="author-info__description">铅华洗尽,一缕芳华</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">20</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">32</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">6</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/FantasticCode2019" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="https://leetcode.cn/u/fantastic_code2018" target="_blank" title="leetcode"><i class="fa-duotone fa-code"></i></a><a class="social-icon" href="mailto:1443996278Yao@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="https://space.bilibili.com/168589693" target="_blank" title="bilibili"><i class="fa-brands fa-bilibili"></i></a><a class="social-icon" href="https://blog.csdn.net/qq_36662611" target="_blank" title="CSDN"><i class="fa-solid fa-c"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#2-docker%E9%95%9C%E5%83%8F%E7%94%B1%E6%9C%AC%E5%9C%B0push%E5%88%B0dockerhub"><span class="toc-number">1.</span> <span class="toc-text">2. docker镜像由本地push到dockerhub</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E6%90%9C%E7%B4%A2%E9%95%9C%E5%83%8F"><span class="toc-number">2.</span> <span class="toc-text">3. 搜索镜像</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-%E4%B8%8B%E8%BD%BD%E9%95%9C%E5%83%8F"><span class="toc-number">3.</span> <span class="toc-text">4. 下载镜像</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#5-%E5%88%97%E5%87%BA%E9%95%9C%E5%83%8F%E7%9B%AE%E5%BD%95"><span class="toc-number">4.</span> <span class="toc-text">5. 列出镜像目录</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#6-%E5%88%9B%E5%BB%BA%E5%AE%B9%E5%99%A8"><span class="toc-number">5.</span> <span class="toc-text">6. 创建容器</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#7-%E6%9F%A5%E7%9C%8B%E5%AE%B9%E5%99%A8%E7%8A%B6%E6%80%81"><span class="toc-number">6.</span> <span class="toc-text">7. 查看容器状态</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#8-%E5%AE%B9%E5%99%A8%E7%9A%84%E9%87%8D%E5%90%AF%E3%80%81%E5%81%9C%E6%AD%A2"><span class="toc-number">7.</span> <span class="toc-text">8. 容器的重启、停止</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#9-%E8%8E%B7%E5%8F%96%E5%AE%B9%E5%99%A8%E7%9A%84Root%E6%9D%83%E9%99%90"><span class="toc-number">8.</span> <span class="toc-text">9. 获取容器的Root权限</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#10-%E6%9F%A5%E7%9C%8B%E5%AE%B9%E5%99%A8%E7%9A%84%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="toc-number">9.</span> <span class="toc-text">10. 查看容器的环境变量</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#11-%E8%BF%9E%E6%8E%A5%E5%AE%B9%E5%99%A8"><span class="toc-number">10.</span> <span class="toc-text">11. 连接容器</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#12-%E5%A4%96%E9%83%A8%E8%BF%90%E8%A1%8C%E5%AE%B9%E5%99%A8%E5%86%85%E5%91%BD%E4%BB%A4"><span class="toc-number">11.</span> <span class="toc-text">12. 外部运行容器内命令</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#13-%E5%88%A0%E9%99%A4%E5%AE%B9%E5%99%A8%E3%80%81%E9%95%9C%E5%83%8F"><span class="toc-number">12.</span> <span class="toc-text">13. 删除容器、镜像</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#14-%E5%AF%BC%E5%85%A5%E5%92%8C%E5%AF%BC%E5%87%BA%E5%AE%B9%E5%99%A8"><span class="toc-number">13.</span> <span class="toc-text">14. 导入和导出容器</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#15-%E6%9F%A5%E7%9C%8B%E9%95%9C%E5%83%8F%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95"><span class="toc-number">14.</span> <span class="toc-text">15. 查看镜像历史记录</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#16-%E4%BD%BF%E7%94%A8cp%E5%91%BD%E4%BB%A4%E5%A4%8D%E5%88%B6%E6%96%87%E4%BB%B6"><span class="toc-number">15.</span> <span class="toc-text">16. 使用cp命令复制文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#17-%E4%BD%BF%E7%94%A8commit%E5%91%BD%E4%BB%A4%E6%8F%90%E4%BA%A4%E5%AE%B9%E5%99%A8%E4%BF%AE%E6%94%B9"><span class="toc-number">16.</span> <span class="toc-text">17. 使用commit命令提交容器修改</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#18-%E4%BD%BF%E7%94%A8diff%E5%91%BD%E4%BB%A4%E6%A3%80%E6%9F%A5%E5%AE%B9%E5%99%A8%E6%96%87%E4%BB%B6%E7%9A%84%E5%8F%98%E5%8A%A8"><span class="toc-number">17.</span> <span class="toc-text">18. 使用diff命令检查容器文件的变动</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#19-%E4%BD%BF%E7%94%A8inspect%E6%9F%A5%E7%9C%8B%E5%AE%B9%E5%99%A8%E3%80%81%E9%95%9C%E5%83%8F%E8%AF%A6%E7%BB%86%E4%BF%A1%E6%81%AF"><span class="toc-number">18.</span> <span class="toc-text">19. 使用inspect查看容器、镜像详细信息</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#20-%E5%9F%BA%E4%BA%8E%E6%9C%AC%E5%9C%B0%E6%A8%A1%E6%9D%BF%E5%AF%BC%E5%85%A5"><span class="toc-number">19.</span> <span class="toc-text">20. 基于本地模板导入</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#21-%E5%AF%BC%E5%87%BA%E5%92%8C%E8%BD%BD%E5%85%A5%E9%95%9C%E5%83%8F"><span class="toc-number">20.</span> <span class="toc-text">21. 导出和载入镜像</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#22-%E6%90%AD%E5%BB%BAdocker%E7%A7%81%E6%9C%89%E4%BB%93%E5%BA%93%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="toc-number">21.</span> <span class="toc-text">22. 搭建docker私有仓库服务器</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#23-Dockerfile%E4%BB%8B%E7%BB%8D"><span class="toc-number">22.</span> <span class="toc-text">23. Dockerfile介绍</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#24-%E5%9F%BA%E4%BA%8EDockerfile%E5%88%9B%E5%BB%BA%E9%95%9C%E5%83%8F"><span class="toc-number">23.</span> <span class="toc-text">24. 基于Dockerfile创建镜像</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/02/08/Hexo%E6%96%B0%E5%BB%BA%E7%AC%AC%E4%B8%80%E7%AF%87%E5%8D%9A%E6%96%87/" title="Hexo新建第一篇博文"><img src="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg1.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Hexo新建第一篇博文"/></a><div class="content"><a class="title" href="/2022/02/08/Hexo%E6%96%B0%E5%BB%BA%E7%AC%AC%E4%B8%80%E7%AF%87%E5%8D%9A%E6%96%87/" title="Hexo新建第一篇博文">Hexo新建第一篇博文</a><time datetime="2022-02-07T16:00:00.000Z" title="发表于 2022-02-08 00:00:00">2022-02-08</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/12/06/1681-%E6%9C%80%E5%B0%8F%E4%B8%8D%E5%85%BC%E5%AE%B9%E6%80%A7/" title="最小不兼容性"><img src="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg7.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="最小不兼容性"/></a><div class="content"><a class="title" href="/2021/12/06/1681-%E6%9C%80%E5%B0%8F%E4%B8%8D%E5%85%BC%E5%AE%B9%E6%80%A7/" title="最小不兼容性">最小不兼容性</a><time datetime="2021-12-05T16:00:00.000Z" title="发表于 2021-12-06 00:00:00">2021-12-06</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2020/12/17/714-%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA%E5%90%AB%E6%89%8B%E7%BB%AD%E8%B4%B9/" title="买卖股票的最佳时机含手续费"><img src="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg20.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="买卖股票的最佳时机含手续费"/></a><div class="content"><a class="title" href="/2020/12/17/714-%E4%B9%B0%E5%8D%96%E8%82%A1%E7%A5%A8%E7%9A%84%E6%9C%80%E4%BD%B3%E6%97%B6%E6%9C%BA%E5%90%AB%E6%89%8B%E7%BB%AD%E8%B4%B9/" title="买卖股票的最佳时机含手续费">买卖股票的最佳时机含手续费</a><time datetime="2020-12-16T16:00:00.000Z" title="发表于 2020-12-17 00:00:00">2020-12-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2020/12/15/AOP/" title="AOP学习"><img src="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg10.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="AOP学习"/></a><div class="content"><a class="title" href="/2020/12/15/AOP/" title="AOP学习">AOP学习</a><time datetime="2020-12-14T16:00:00.000Z" title="发表于 2020-12-15 00:00:00">2020-12-15</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2020/12/15/docker%E5%91%BD%E4%BB%A4/" title="docker命令"><img src="https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg16.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="docker命令"/></a><div class="content"><a class="title" href="/2020/12/15/docker%E5%91%BD%E4%BB%A4/" title="docker命令">docker命令</a><time datetime="2020-12-14T16:00:00.000Z" title="发表于 2020-12-15 00:00:00">2020-12-15</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://cdn.jsdelivr.net/gh/FantasticCode2019/cdn/backgroud/bg16.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2022 By FantasticCode</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Hi, welcome to my <a href="https://yyj_challenged.gitee.io//">blog</a>!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="聊天"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="algolia-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="search-wrap"><div id="algolia-search-input"></div><hr/><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-info"><div class="algolia-stats"></div><div class="algolia-poweredBy"></div></div></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page@5/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="https://cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch-lite.umd.js"></script><script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4/dist/instantsearch.production.min.js"></script><script src="/js/search/algolia.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>function addGitalkSource () {
  const ele = document.createElement('link')
  ele.rel = 'stylesheet'
  ele.href= 'https://cdn.jsdelivr.net/npm/gitalk/dist/gitalk.min.css'
  document.getElementsByTagName('head')[0].appendChild(ele)
}

function loadGitalk () {
  function initGitalk () {
    var gitalk = new Gitalk(Object.assign({
      clientID: 'ea007ab939d0b7d664ea',
      clientSecret: '7f9f6bf9d107c6b3f99a5fe05e343ddd631adf82',
      repo: 'yyj_challenged',
      owner: 'FantasticCode2019',
      admin: ['FantasticCode2019'],
      id: '548eea74d575d1da1ea36d4da1037184',
      updateCountCallback: commentCount
    },null))

    gitalk.render('gitalk-container')
  }

  if (typeof Gitalk === 'function') initGitalk()
  else {
    addGitalkSource()
    getScript('https://cdn.jsdelivr.net/npm/gitalk@latest/dist/gitalk.min.js').then(initGitalk)
  }
}

function commentCount(n){
  let isCommentCount = document.querySelector('#post-meta .gitalk-comment-count')
  if (isCommentCount) {
    isCommentCount.innerHTML= n
  }
}

if ('Gitalk' === 'Gitalk' || !true) {
  if (true) btf.loadComment(document.getElementById('gitalk-container'), loadGitalk)
  else loadGitalk()
} else {
  function loadOtherComment () {
    loadGitalk()
  }
}</script></div><canvas class="fireworks" mobile="false"></canvas><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/fireworks.min.js"></script><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="true" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>